<#assign menu="push">
<#assign submenu="push_list">
<#include "/system/head.ftl">
<style type="text/css" xmlns="http://www.w3.org/1999/html">
    .pagination {
        border-radius: 4px;
        display: inline-block;
        margin: 0;
        padding-left: 0;
    }

    /* Portlet */
    .portlet > .portlet-body.green,
    .portlet.green {
        background-color: white;
    }


</style>

<body>

<section id="main-content">
    <section class="wrapper">

        <div class="row">
            <div class="col-md-12">
                <div class="portlet box grey-cascade">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="fa fa-globe"></i>推送管理
                        </div>
                        <div class="tools">
                            <a href="javascript:;" class="collapse">
                            </a>
                            <a href="javascript:;" class="reload">
                            </a>
                            <a href="javascript:;" class="remove">
                            </a>
                        </div>
                    </div>
                    <div class="portlet-body">
                        <div class="table-toolbar">
                            <div class="btn-group">
                                <a href="${basePath}/admin/push/add.htm" class="btn green" id="sample_editable_1_new">
                                    添加 <i class="fa fa-plus"></i>
                                </a>
                            </div>
                        </div>

                        <table  class="table table-striped table-bordered table-hover" id="sample_1">
                            <thead>
                            <tr>
                                <th class="table-checkbox">
                                    <input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"/>
                                </th>
                                <th>编号</th>
                                <th>组名</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <#list pushList as e>
                            <tr class="gradeA odd">
                                <td>
                                    <input type="checkbox" class="checkboxes" value="1"/>
                                </td>

                                <td>
                                ${e.id}
                                </td>
                                <td>
                                    <a href="${basePath}/admin/push/edit.htm?pushId=${e.id}">${e.name}</a></td>
                                <td>
                                    <#if e.available==1>
                                        <a href="javascript:void(0);" class="js_push_delete btn btn-sm blue" pushId="${e.id}"
                                           title="是否删除此兴趣">
                                            禁用
                                        </a>
                                    </#if>
                                    <#if e.available==0>
                                        <a href="javascript:void(0);" class="js_push_on btn btn-sm blue" pushId="${e.id}"
                                           title="是否启用此兴趣">
                                            启用
                                        </a>
                                    </#if>
                                </td>


                            </tr>
                            </#list>

                            </tbody>
                        </table>
                    </div>

                </div>

            </div>
        </div>
    </section>
</section>


</body>
<#include "../foot.ftl">

<script>
    var TableManaged = function () {
        return {
            //main function to initiate the module
            init: function () {
                if (!jQuery().dataTable) {
                    return;
                }
                // begin first table
                $('#sample_1').dataTable({
                    "aoColumns": [
                        { "bSortable": false },
                        { "bSortable": true },
                        { "bSortable": false },
                        { "bSortable": false}
                    ],
                    "aLengthMenu": [
                        [5, 15, 20, -1],
                        [5, 15, 20, "All"] // change per page values here
                    ],
                    // set the initial value
                    "iDisplayLength": 5,
                    "sPaginationType": "bootstrap",
                    "oLanguage": {
                        "sLengthMenu": "_MENU_ records",
                        "oPaginate": {
                            "sPrevious": "Prev",
                            "sNext": "Next"
                        }
                    },
                    "aoColumnDefs": [
                        { 'bSortable': false, 'aTargets': [0] },
                        { "bSearchable": false, "aTargets": [ 0 ] }
                    ]
                });

                jQuery('#sample_1 .group-checkable').change(function () {
                    var set = jQuery(this).attr("data-set");
                    var checked = jQuery(this).is(":checked");
                    jQuery(set).each(function () {
                        if (checked) {
                            $(this).attr("checked", true);
                            $(this).parents('tr').addClass("active");
                        } else {
                            $(this).attr("checked", false);
                            $(this).parents('tr').removeClass("active");
                        }
                    });
                    jQuery.uniform.update(set);
                });

                jQuery('#sample_1').on('change', 'tbody tr .checkboxes', function(){
                    $(this).parents('tr').toggleClass("active");
                });

                jQuery('#sample_1_wrapper .dataTables_filter input').addClass("form-control input-medium input-inline"); // modify table search input
                jQuery('#sample_1_wrapper .dataTables_length select').addClass("form-control input-xsmall input-inline"); // modify table per page dropdown


            }
        };
    }();
    TableManaged.init();
</script>
<script>
    $(function () {
        $('.js_push_delete').click(function () {
            var pushId = $(this).attr('pushId');
            var status = "trash";
            bootbox.dialog({
                message: $(this).attr('title'),
                title: "提示",
                buttons: {
                    "delete": {
                        label: "确定",
                        className: "btn-success",
                        callback: function () {
                            $.post("${basePath}/admin/push/delete.json", {"pushId": pushId}, function (data) {
                                window.location.reload();
                            }, "json");
                        }
                    },
                    "cancel": {
                        label: "取消",
                        className: "btn-primary",
                        callback: function () {

                        }
                    }
                }
            });
        });

        $('.js_push_on').click(function () {
            var pushId = $(this).attr('pushId');
            var status = "trash";
            bootbox.dialog({
                message: $(this).attr('title'),
                title: "提示",
                buttons: {
                    "delete": {
                        label: "确定",
                        className: "btn-success",
                        callback: function () {
                            $.post("${basePath}/admin/push/getOn.json", {"pushId": pushId}, function (data) {
                                window.location.reload();
                            }, "json");
                        }
                    },
                    "cancel": {
                        label: "取消",
                        className: "btn-primary",
                        callback: function () {

                        }
                    }
                }
            });
        });

    });
</script>

